package com.example.qxfw.ybzz.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.xt.YbzzConfig;
import com.example.qxfw.common.entity.xt.YbzzStationConfig;
import com.example.qxfw.ybzz.service.YbzzConfigService;
import com.example.qxfw.ybzz.service.YbzzStationConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@ApiIgnore
@Api(tags = "预报制作-格点路径配置")
@RestController
@CrossOrigin
@RequestMapping("/gdljpz")
public class GdljpzController {

    @Autowired
    private YbzzConfigService ybzzConfigService;

    @Autowired
    private YbzzStationConfigService ybzzStationConfigService;

    //格点路径配置
    @ApiOperation("获取格点资料设置")
    @GetMapping("/getYbzzConfig")
    public SysResult getYbzzConfig(String mappedpath){
        List<YbzzConfig> ybzzConfigs = ybzzConfigService.getListByPath(mappedpath);
        return SysResult.success(ybzzConfigs);
    }

    @ApiOperation("更新格点资料设置")
    @PostMapping("/updateYbzzConfig")
    public SysResult updateYbzzConfig(@RequestBody YbzzConfig ybzzConfig){
        int rows = ybzzConfigService.updateByType(ybzzConfig);
        return SysResult.success(rows);
    }

    @ApiOperation("获取预报站点设置")
    @GetMapping("/getYbzzStationConfig")
    public SysResult getYbzzStationConfig(){
        List<YbzzStationConfig> ybzzStationConfigs = ybzzStationConfigService.getList();
        return SysResult.success(ybzzStationConfigs);
    }

    @ApiOperation("更新预报站点配置")
    @PostMapping("/updateYbzzStationConfig")
    public SysResult updateYbzzStationConfig(@RequestBody YbzzStationConfig ybzzStationConfig){
        int rows = ybzzStationConfigService.updateByType(ybzzStationConfig);
        return SysResult.success(rows);
    }
}
